package com.lhb.user.mapper;

import com.lhb.user.model.LoginVO;
import com.lhb.user.model.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    @Update("update user set password=#{newPassword} where email=#{email}")
    void updateUserByEmail(@Param("email") String email, @Param("newPassword") String newPassword);
    @Insert("insert into user(username, email, password) values (#{username},#{email},#{password})")
    void register(User user);
    @Select("select id, username, email, password from user where email=#{email} and password=#{password}")
    LoginVO login(@Param("email") String email, @Param("password") String password);

    @Select("select id, username, email, password from user where id=#{id}")
    User getUserById(@Param("id") Long id);

    @Update("update user set password=#{newPassword} where id=#{id}")
    void modifyPassword(@Param("id") Long id, @Param("newPassword") String newPassword);

    @Update("update user set email=#{email} where id=#{id}")
    void modifyEmail(@Param("id") Long id, @Param("email") String email);
}
